use strict;
use warnings;

use Country;

while (my $line = <>) {
	chomp $line;
	if ($line =~ /^(\+\d*\s*\d+)\s*([A-Z]{2})/) {
		my $prefix = $1;
		my $country_code = $2;
		
		#print "$prefix\t$country_code\n";
		my $p = Country->new('id' => $country_code);
		my $rv = $p->load('speculative' => 1);
		if ($rv) {
			$p->calling_prefix($prefix);
			$p->save();
		} else {
			warn "Can't find $country_code";
		}
	} else {
		warn $line;
	}
}